package com.starbucks.opencase.function;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.starbucks.opencase.enums.enumCMKey;
import com.starbucks.opencase.enums.enumCMTip;
import org.springframework.stereotype.Component;

@Component
public class funTest {
    public boolean hasPhone(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.phone.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_phone.getTip());
        return false;
    }
    public String getPhone(JsonNode me){
        return me.get(enumCMKey.phone.name()).asText();
    }
    public boolean hasCommand(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.command.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_command.getTip());
        return false;
    }
    public String getCommand(JsonNode me){
        return me.get(enumCMKey.command.name()).asText();
    }
    public boolean hasNowPageNum(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.nowPageNum.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_now_page_num.getTip());
        return false;
    }
    public int getNowPageNum(JsonNode me){
        return me.get(enumCMKey.nowPageNum.name()).asInt();
    }
    public boolean hasNickname(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.nickname.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_nickname.getTip());
        return false;
    }
    public String getNickname(JsonNode me){
        return me.get(enumCMKey.nickname.name()).asText();
    }
    public boolean hasName(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.name.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_name.getTip());
        return false;
    }
    public String getName(JsonNode me){
        return me.get(enumCMKey.name.name()).asText();
    }
    public boolean hasData(JsonNode me,ObjectNode on){
        if(me.has(enumCMKey.data.name()))return true;
        on.put(enumCMKey.status.name(), false);
        on.put(enumCMKey.tip.name(), enumCMTip.no_has_data.getTip());
        return false;
    }
    public String getData(JsonNode me){
        return me.get(enumCMKey.data.name()).asText();
    }
}
